package com.campus.food.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 订单详情实体类
 * 对应数据库表：t_order_detail
 * 
 * @author Claude3.7 Sonnet
 * @since 2025-05-29
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class OrderDetail {
    
    /**
     * 订单详情ID
     */
    private Long id;
    
    /**
     * 订单ID
     */
    private Long orderId;
    
    /**
     * 菜品ID
     */
    private Long foodId;
    
    /**
     * 菜品名称
     */
    private String foodName;
    
    /**
     * 菜品图片URL
     */
    private String foodImage;
    
    /**
     * 菜品单价
     */
    private BigDecimal price;
    
    /**
     * 购买数量
     */
    private Integer quantity;
    
    /**
     * 小计金额
     */
    private BigDecimal subtotal;
    
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    
    /**
     * 设置菜品价格（兼容方法）
     */
    public void setFoodPrice(BigDecimal price) {
        this.price = price;
    }
} 